package edu.sctu.demo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by 1 on 2018/6/18.
 */
public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username=req.getParameter("username");
        String password=req.getParameter("password");
        HttpSession session=req.getSession(true);

        if ("john".equals(username) && "123456".equals(password)) {
            session.setAttribute("islogin", "true");
            resp.sendRedirect("userList");

        } else {
            session.setAttribute("islogin", "fals");
            session.setAttribute("wrong", "default");
            resp.sendRedirect("login.jsp");

        }
        resp.setCharacterEncoding("gbk");
    }
}
